public class NumSumFactorial {
    public static void main(String[] args) {
    int n=sum(4);
        System.out.println(n);
    }
    public static int sum(int n){
    if(n==1){
        return 1;
    }
    int y=sum(n-1);
    int x=factorial(n);
    return x+y;
    }

    public static int factorial(int n){
        if(n==1){
            return 1;
        }
        int x=factorial(n-1);
        return x*n;
    }
        }
